package net.zeus.rabbitmq.direct;

import org.springframework.amqp.core.ExchangeTypes;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

/**
 * 消息接受监听
 * 
 * @author Michael
 *
 */
@Component
@RabbitListener(
		// 绑定
		bindings=@QueueBinding(
				// 配置队列，value为队列名
				value=@Queue(value="${net.zeus.queue-info}"),
				// 配置交换器，value-交换器名，type-分发类型(fanout,direct,topic)
				exchange=@Exchange(value="${net.zeus.exchange}", type=ExchangeTypes.DIRECT),
				// 路由键
				key="${net.zeus.key-info}"
			)
		)
public class InfoLogListener {

	@RabbitHandler
	public void infoProcess(String msg) {
		System.out.println("info listener->" + msg);
		if("hello admin".equals(msg)) {
			throw new RuntimeException("hello");
		}
	}
	
}
